/*
 * Copyright (C) 2014 Realtek Semiconductor Corp.
 * All Rights Reserved.
 *
 * This program is the proprietary software of Realtek Semiconductor
 * Corporation and/or its licensors, and only be used, duplicated,
 * modified or distributed under the authorized license from Realtek.
 *
 * ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
 * THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
 *
 * Purpose : Definition of OMCI MIB related info
 *
 * Feature : The file includes the following modules and sub-modules
 *           (1) OMCI MIB definition
 */

#ifndef __OMCI_MIB_H__
#define __OMCI_MIB_H__

#ifdef __cplusplus
extern "C" {
#endif


#include "../inc/omci_protocol.h"


#ifdef KAON_CUSTOMER_SKB
typedef enum
{
    NAT_DEVICE_MODE,
    BRIDGE_DEVICE_MODE,
} NETWORK_MODE;
#endif

typedef enum
{
    OMCI_ME_INIT_TYPE_ONU,
    OMCI_ME_INIT_TYPE_OLT,
} omci_me_init_type_t;

typedef enum
{
	// single selection
    OMCI_ME_TYPE_STANDARD       = 0x01,
    OMCI_ME_TYPE_STANDARD_PM    = 0x02,
    OMCI_ME_TYPE_PROPRIETARY    = 0x04,
    OMCI_ME_TYPE_PROPRIETARY_PM = 0x08,
    OMCI_ME_TYPE_PRIVATE        = 0x10,

	// multiple selection
    OMCI_ME_TYPE_NOT_MIB_UPLOAD = 0x100,
} omci_me_type_t;

typedef enum
{
    OMCI_ME_ATTR_ACCESS_READ	= 0x1,
    OMCI_ME_ATTR_ACCESS_WRITE	= 0x2,
    OMCI_ME_ATTR_ACCESS_SBC		= 0x4,
} omci_me_attr_access_mask_t;

typedef enum
{
	// single selection
	OMCI_ME_ATTR_TYPE_MANDATORY			= 0x01,
	OMCI_ME_ATTR_TYPE_M_NOT_SUPPORT		= 0x02,
	OMCI_ME_ATTR_TYPE_OPTIONAL			= 0x04,
	OMCI_ME_ATTR_TYPE_O_NOT_SUPPORT		= 0x08,
	OMCI_ME_ATTR_TYPE_PRIVATE			= 0x10,

	// multiple selection
    OMCI_ME_ATTR_TYPE_PM				= 0x100,
    OMCI_ME_ATTR_TYPE_TABLE				= 0x200,
} omci_me_attr_type_mask_t;

/* G.988 A.1.4.3 - Alarm reporting control */
typedef enum {
    OMCI_ME_ATTR_ARC_DISABLED	= 0,
    OMCI_ME_ATTR_ARC_ENABLED	= 1,
} omci_me_attr_arc_t;

typedef enum {
    OMCI_ME_ATTR_ARC_INTERVAL_EXPIRED_NOW		= 0,
    OMCI_ME_ATTR_ARC_INTERVAL_NEVER_EXPIRED		= 255,
} omci_me_attr_arc_interval_t;

/* G.988 A.1.6 - Administrative state considerations */
typedef enum {
    OMCI_ME_ATTR_ADMIN_STATE_UNLOCK		= 0,
    OMCI_ME_ATTR_ADMIN_STATE_LOCK		= 1,
    OMCI_ME_ATTR_ADMIN_STATE_SHUTDOWN   = 2,
} omci_me_attr_admin_state_t;

typedef enum {
    OMCI_ME_ATTR_OP_STATE_ENABLED   = 0,
    OMCI_ME_ATTR_OP_STATE_DISABLED	= 1,
} omci_me_attr_op_state_t;

typedef UINT32 omci_me_action_mask_t;

enum
{
    OMCI_ME_ACTION_CREATE				= (1 << OMCI_MSG_TYPE_CREATE),
    OMCI_ME_ACTION_DELETE				= (1 << OMCI_MSG_TYPE_DELETE),
    OMCI_ME_ACTION_SET					= (1 << OMCI_MSG_TYPE_SET),
    OMCI_ME_ACTION_GET					= (1 << OMCI_MSG_TYPE_GET),
    OMCI_ME_ACTION_GET_ALL_ALARMS		= (1 << OMCI_MSG_TYPE_GET_ALL_ALARMS),
    OMCI_ME_ACTION_GET_ALL_ALARMS_NEXT	= (1 << OMCI_MSG_TYPE_GET_ALL_ALARMS_NEXT),
    OMCI_ME_ACTION_MIB_UPLOAD			= (1 << OMCI_MSG_TYPE_MIB_UPLOAD),
    OMCI_ME_ACTION_MIB_UPLOAD_NEXT		= (1 << OMCI_MSG_TYPE_MIB_UPLOAD_NEXT),
    OMCI_ME_ACTION_MIB_RESET			= (1 << OMCI_MSG_TYPE_MIB_RESET),
    OMCI_ME_ACTION_ALARM				= (1 << OMCI_MSG_TYPE_ALARM),
    OMCI_ME_ACTION_ATTR_VALUE_CHANGE	= (1 << OMCI_MSG_TYPE_ATTR_VALUE_CHANGE),
    OMCI_ME_ACTION_TEST					= (1 << OMCI_MSG_TYPE_TEST),
    OMCI_ME_ACTION_START_SW_DOWNLOAD	= (1 << OMCI_MSG_TYPE_START_SW_DOWNLOAD),
    OMCI_ME_ACTION_DOWNLOAD_SECTION		= (1 << OMCI_MSG_TYPE_DOWNLOAD_SECTION),
    OMCI_ME_ACTION_END_SW_DOWNLOAD		= (1 << OMCI_MSG_TYPE_END_SW_DOWNLOAD),
    OMCI_ME_ACTION_ACTIVATE_SW			= (1 << OMCI_MSG_TYPE_ACTIVATE_SW),
    OMCI_ME_ACTION_COMMIT_SW			= (1 << OMCI_MSG_TYPE_COMMIT_SW),
    OMCI_ME_ACTION_SYNCHRONIZE_TIME		= (1 << OMCI_MSG_TYPE_SYNCHRONIZE_TIME),
    OMCI_ME_ACTION_REBOOT				= (1 << OMCI_MSG_TYPE_REBOOT),
    OMCI_ME_ACTION_GET_NEXT				= (1 << OMCI_MSG_TYPE_GET_NEXT),
    OMCI_ME_ACTION_TEST_RESULT			= (1 << OMCI_MSG_TYPE_TEST_RESULT),
    OMCI_ME_ACTION_GET_CURRENT_DATA		= (1 << OMCI_MSG_TYPE_GET_CURRENT_DATA),
    OMCI_ME_ACTION_SET_TABLE			= (1 << OMCI_MSG_TYPE_SET_TABLE)
};

/* G.988 Table 9.1.5-1 - Plug-in unit types */
typedef enum {
    OMCI_PLUGIN_UNIT_TYPE_10BASE_T                    = 22,
    OMCI_PLUGIN_UNIT_TYPE_100BASE_T                    = 23,
    OMCI_PLUGIN_UNIT_TYPE_10_100BASE_T                = 24,
    OMCI_PLUGIN_UNIT_TYPE_POTS                        = 32,
    OMCI_PLUGIN_UNIT_TYPE_GIGABIT_OPTICAL_ETHERNET    = 34,
    OMCI_PLUGIN_UNIT_TYPE_XDSL                        = 35,
    OMCI_PLUGIN_UNIT_TYPE_VDSL                        = 37,
    OMCI_PLUGIN_UNIT_TYPE_VIDEO_SERVICE                = 38,
    OMCI_PLUGIN_UNIT_TYPE_LCT                        = 39,
    OMCI_PLUGIN_UNIT_TYPE_802_11                    = 40,
    OMCI_PLUGIN_UNIT_TYPE_MOCA                        = 46,
    OMCI_PLUGIN_UNIT_TYPE_10_100_1000BASE_T            = 47,
    OMCI_PLUGIN_UNIT_TYPE_VEIP                        = 48,
    OMCI_PLUGIN_UNIT_TYPE_10GBASE_T_ETHERNET        = 49,
    OMCI_PLUGIN_UNIT_TYPE_2P5GBASE_T_ETHERNET        = 50,   /*IEEE 802.3 2.5GBASE-T Ethernet LAN interface */
    OMCI_PLUGIN_UNIT_TYPE_XG_PON10G2488             = 237,
    OMCI_PLUGIN_UNIT_TYPE_XG_PON10G10                = 238,
    OMCI_PLUGIN_UNIT_TYPE_GPON_24881244                = 248,
} omci_plugin_unit_type_t;


#define OMCI_MIB_US_TM_ME_ID_BASE	(0x8000)
#define OMCI_MIB_US_TM_ME_RSV_ID_BASE	(0xFF00)

/* ONT-G  */
#define TXC_ONUG_INSTANCE_ID (0)


/* ONT2-G */
#define TXC_ONU2G_INSTANCE_ID (0)


/* CardHolder */
#define OMCI_ME_ID_CARDHOLDER_INTEGRATED_SLOT   (0)
#define OMCI_ME_ID_CARDHOLDER_RESERVED_SLOT     (255)
#define TXC_CARDHLD_SLOT_TYPE_PLUGGABLE		(0x00 << 8)
#define TXC_CARDHLD_SLOT_TYPE_INTEGRATED	(0x01 << 8)
#define TXC_CARDHLD_PON_SLOT_TYPE_ID  (0x80)
#define TXC_CARDHLD_GE_SLOT_TYPE_ID   (0x1)
#define TXC_CARDHLD_POTS_SLOT_TYPE_ID (0x2)
#define TXC_CARDHLD_XE_SLOT_TYPE_ID   (0x3)
#define TXC_CARDHLD_FE_SLOT_TYPE_ID   (0x4)
#define TXC_CARDHLD_2P5GE_SLOT_TYPE_ID   (0x5)
#define TXC_CARDHLD_VEIP_SLOT_TYPE_ID (0x6)
#define TXC_CARDHLD_CATV_SLOT_TYPE_ID (0xb)

#define OMCI_PLUGIN_UNIT_TYPE_PON ((gInfo.ponSpeed == OMCI_PON_SPEED_GPON) ? OMCI_PLUGIN_UNIT_TYPE_GPON_24881244:	\
( gInfo.ponSpeed  == OMCI_PON_SPEED_XGPON1) ? (OMCI_PLUGIN_UNIT_TYPE_XG_PON10G2488)  :	\
( gInfo.ponSpeed  == OMCI_PON_SPEED_XGSPON) ? (OMCI_PLUGIN_UNIT_TYPE_XG_PON10G10) : \
					       OMCI_PLUGIN_UNIT_TYPE_GPON_24881244)



#define m_omci_is_slot_id_valid(x)    (TXC_CARDHLD_PON_SLOT_TYPE_ID == x || \
                                        gInfo.txc_cardhld_fe_slot_type_id == x || \
                                        TXC_CARDHLD_GE_SLOT_TYPE_ID == x || \
                                        TXC_CARDHLD_POTS_SLOT_TYPE_ID == x || \
                                        TXC_CARDHLD_VEIP_SLOT_TYPE_ID == x || \
                                        TXC_CARDHLD_CATV_SLOT_TYPE_ID == x || \
                                        TXC_CARDHLD_XE_SLOT_TYPE_ID == x || \
                                        TXC_CARDHLD_2P5GE_SLOT_TYPE_ID == x)

#define OMCI_IS_PLUGIN_UNIT_TYPE_VALID(x) (OMCI_PLUGIN_UNIT_TYPE_GPON_24881244 == x || \
                                            OMCI_PLUGIN_UNIT_TYPE_XG_PON10G2488 == x || \
                                            OMCI_PLUGIN_UNIT_TYPE_XG_PON10G10 == x || \
                                            OMCI_PLUGIN_UNIT_TYPE_10_100BASE_T == x || \
                                            OMCI_PLUGIN_UNIT_TYPE_10_100_1000BASE_T == x || \
                                            OMCI_PLUGIN_UNIT_TYPE_POTS == x || \
                                            OMCI_PLUGIN_UNIT_TYPE_VEIP == x || \
                                            OMCI_PLUGIN_UNIT_TYPE_VIDEO_SERVICE == x || \
                                            OMCI_PLUGIN_UNIT_TYPE_10GBASE_T_ETHERNET == x || \
                                            OMCI_PLUGIN_UNIT_TYPE_2P5GBASE_T_ETHERNET == x)

// ethernet mode: ( 4 X FE + 1 X GE ) or ( 2 X GE ), port id from 0 to 4


#define TXC_CARDHLD_PON_SLOT        (0)
#define TXC_CARDHLD_ETH_GE_SLOT     (1)
#define TXC_CARDHLD_ETH_FE_SLOT     (2)
#define TXC_CARDHLD_VEIP_SLOT       (3)
#define TXC_CARDHLD_POTS_SLOT       (4)
#define TXC_CARDHLD_CATV_SLOT       (5)
#define TXC_CARDHLD_ETH_XE_SLOT    (6)
#define TXC_CARDHLD_ETH_2P5GE_SLOT  (7)

#define TXC_CARDHLD_SLOT_NUM     (8)


#define TXC_GET_CARDTYPE_BY_SLOT_ID(slotId) (( slotId  == TXC_CARDHLD_PON_SLOT)    ? (OMCI_PLUGIN_UNIT_TYPE_PON) :   \
( slotId  == TXC_CARDHLD_ETH_FE_SLOT) ? (OMCI_PLUGIN_UNIT_TYPE_10_100BASE_T)  :   \
( slotId  == TXC_CARDHLD_ETH_GE_SLOT) ? (OMCI_PLUGIN_UNIT_TYPE_10_100_1000BASE_T)  :   \
( slotId  == TXC_CARDHLD_POTS_SLOT) ? (OMCI_PLUGIN_UNIT_TYPE_POTS)  :   \
( slotId  == TXC_CARDHLD_CATV_SLOT) ? (OMCI_PLUGIN_UNIT_TYPE_VIDEO_SERVICE)  :   \
( slotId  == TXC_CARDHLD_VEIP_SLOT) ? (OMCI_PLUGIN_UNIT_TYPE_VEIP)  :   \
( slotId  == TXC_CARDHLD_ETH_XE_SLOT) ? (OMCI_PLUGIN_UNIT_TYPE_10GBASE_T_ETHERNET)  :   \
OMCI_PLUGIN_UNIT_TYPE_2P5GBASE_T_ETHERNET)

#define TXC_GET_SLOT_NUM_BY_SLOT_ID(slotId) ((slotId) == TXC_CARDHLD_PON_SLOT ? TXC_CARDHLD_PON_SLOT_TYPE_ID : \
                                             (slotId) == TXC_CARDHLD_ETH_FE_SLOT ? gInfo.txc_cardhld_fe_slot_type_id : \
                                             (slotId) == TXC_CARDHLD_ETH_GE_SLOT ? TXC_CARDHLD_GE_SLOT_TYPE_ID : \
                                             (slotId) == TXC_CARDHLD_POTS_SLOT ? TXC_CARDHLD_POTS_SLOT_TYPE_ID : \
                                             (slotId) == TXC_CARDHLD_CATV_SLOT ? TXC_CARDHLD_CATV_SLOT_TYPE_ID : \
                                             (slotId) == TXC_CARDHLD_VEIP_SLOT ? TXC_CARDHLD_VEIP_SLOT_TYPE_ID : \
                                             (slotId) == TXC_CARDHLD_ETH_XE_SLOT ? TXC_CARDHLD_XE_SLOT_TYPE_ID : \
                                              TXC_CARDHLD_2P5GE_SLOT_TYPE_ID)


// not sure
#define TXC_PRIO_Q_MAX_SIZE        (0xCCC)


/*SWImage*/
#define TXC_DEFAULT_SW_VERSION    "RTL9600V1.01"

#define OMCI_SW_DL_IMAGE_UBOOT_FLAG_NAME	(32)
#define OMCI_SW_DL_IMAGE_UBOOT_FLAG_BUFFER	(32)
#define OMCI_SW_DL_IMAGE_UBOOT_FLAG_COMMAND_BUFFER \
	(OMCI_SW_DL_IMAGE_UBOOT_FLAG_NAME + OMCI_SW_DL_IMAGE_UBOOT_FLAG_BUFFER + 32)

#define OMCI_BOA_MIB_BUFFER_LEN             (256)

/* IP Host Number */
#define TXC_IPHOST_NUM              (3)

/* FTTR number*/
#define FTTR_P2MP_SFU_NUM   (16)
#define FTTR_P2MP_MFU_POT_NUM   (1)

/*MIB MIB_PON_DETECT_CONTROL_FLAG ,
CTRL_FLAG_RX_LOS_DETECT_ENABLE 8 //enable detect under RX LOS: only support GPON+XGPON or GPON+XGSPON*/
#define IS_RUN_PON_SPEED_AUTO(_flag)    ((_flag) & 0x8)

/*PON_DETECT_AVAILABLE_GPON_FLAG
enabled GPON mode flags for auto select */
#define IS_SUPPORT_PON_SPEED_GPON(_flag)    ((_flag) & 0x1)
#define IS_SUPPORT_PON_SPEED_XGPON(_flag)    ((_flag) & 0x4)
#define IS_SUPPORT_PON_SPEED_XGSPON(_flag)    ((_flag) & 0x8)

#ifdef __cplusplus
}
#endif

#endif
